from common.basepage import BasePage


# 封装登录页面 # 用到的页面元素  ,
class LoginPage(BasePage):
    def __init__(self,driver):
        super().__init__(driver)
        # 页面元素的定位方式
        self.account_loc="id=account"
        self.password_loc="id=password"
        self.submit_loc = "id=submit"
        self.assert_text_loc = "css selector=.bootbox-body"

    def type_account(self,name):
        self.input(self.account_loc,name)

    def type_password(self,password):
        self.input(self.password_loc,password)
    def type_submit(self):
        self.button(self.submit_loc)
    def assret_text(self):
        return self.get_text(self.assert_text_loc)
class MainPage(BasePage):

    def __init__(self, driver):
        super().__init__(driver)
        self.backstage_loc = "xpath, //li[@id='s-menu-superadmin']"
        self.framename_loc = "iframe-superadmin"
        self.useradd_loc = 'xpath, //*[@id="shortcutBox"]/div/div[1]/div/a/h3'
        self.assert_text_loc = "link text=签退"

    # 点击后台管理
    def type_backstage(self):
        self.button(self.backstage_loc)
        # self.driver.find_element("By.LINK_TEXT, '签退'").click()
        # self.click(self.backstage_loc)

    # 后台管理模块里面的添加成员
    def type_useradd(self):
        self.switch_to_frame(self.framename_loc)
        self.button(self.useradd_loc)

    def type_off(self):
        self.button(self.assert_text_loc)
    # 断言信息 用元素属性 ，或者文本值， 或者元素是否出现
    def assert_text(self):
        return self.get_text(self.assert_text_loc)